home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / suckmods.zip / SUCKMODS.ZIP / suck05 / src / admin.qc next >
Text File  |  1997-05-09  |  5KB  |  205 lines

  1. //---------------------------------------------------------------------------
  2. //Quake
  3. //
  4. //Copyright (c) 1995-96 by Dave Kirsch
  5. //---------------------------------------------------------------------------
  6. //admin - remove server admin functions
  7. //---------------------------------------------------------------------------
  8.  
  9. .float accesslvl; // current access level
  10. .float accessparm; // current access parm
  11.  
  12. // NOTE:  THE FOLLOWING VALUES ARE THE PASSWORD USED TO ENABLE
  13. // REMOTE ACCESS.
  14. //
  15. // The have the following properties and requirements:
  16. // a. Must not be an existing impulse
  17. // b. Must be entered in the specified order
  18. // c. Must be in the range 1 to 255 excluding previously used impulses
  19. //
  20. // They must be entered in the correct order which gives 256*256*256 or
  21. // 16777216 possible passwords.  If a specified order wasn't given, it
  22. // would only be 768 possibilities.
  23. //
  24. // BY DEFAULT, REMOTE ADMIN ACCESS IS DISABLED
  25. // This is done by setting the admin passwords all to -1.
  26. //
  27. // If you wanted to enable it, pick three random numbers (that aren't
  28. // existing impulses) and put 'em here, for example:
  29. //
  30. //        float    ADMIN_PWD_1    = 179;
  31. //        float    ADMIN_PWD_2    = 131;
  32. //        float    ADMIN_PWD_3    = 157;
  33. //
  34. // which would give you a password of 179, 131 and 157.  To send this from
  35. // a Quake client, do a bind like this:
  36. //
  37. // bind p "impulse 179;wait;impulse 131;wait;impulse 157"
  38. //
  39. // When you hit p, you'll be granted remote admin functionality.
  40. //
  41. // Currently the only admin functions available right now are kick
  42. // and team change.  They are bound to impulse 151 and impulse 152.
  43. //
  44. // The way it works is after you enter the admin password, do an
  45. // impulse 151/152.  You'll get a list of players on the server with their
  46. // numbers.  Send the next impulse with the number of the player
  47. // to act the command on.
  48.  
  49. float    ADMIN_PWD_1    = 233;  // change me to first number of the passwd
  50. float    ADMIN_PWD_2    = 211;  // change me to second number of the passwd
  51. float    ADMIN_PWD_3    = 233;  // change me to third number of the passwd
  52.  
  53. float    ADMIN_KICK = 151;
  54. float    ADMIN_TEAMCHANGE = 152;
  55. float    ADMIN_CHANGELEVEL = 153;
  56. void() CheckAdminCmd =
  57. {
  58.     local float n;
  59.     local entity p;
  60.     local string s;
  61.  
  62.     if (ADMIN_PWD_1 < 0 || ADMIN_PWD_2 < 0 || ADMIN_PWD_3 < 0)
  63.         return; // disabled
  64.  
  65.     if (self.impulse == ADMIN_PWD_1 && self.accesslvl == 0)
  66.         self.accesslvl = self.accesslvl + 1;
  67.  
  68.     else if (self.impulse == ADMIN_PWD_2 && self.accesslvl == 1)
  69.         self.accesslvl = self.accesslvl + 1;
  70.  
  71.     else if (self.impulse == ADMIN_PWD_3 && self.accesslvl == 2) {
  72.         self.accesslvl = self.accesslvl + 1;
  73.  
  74.         bprint(self.netname);
  75.         bprint(" has become a sysop\n");
  76.  
  77.         sprint(self, "Admin:\nImpulse ");
  78.         s = ftos(ADMIN_KICK);
  79.         sprint(self, s);
  80.         sprint(self, " to kick\nImpulse ");
  81.         s = ftos(ADMIN_TEAMCHANGE);
  82.         sprint(self, s);
  83.         sprint(self, " to switch teamplayer\n");
  84.         self.accessparm = 0;
  85.         return;
  86.     }
  87.  
  88.     if (self.accesslvl < 3) {
  89.         self.accessparm = 0;
  90.         return; // must be a sysop beyond this point
  91.     }
  92.  
  93.     if (self.accessparm == 1) { // kick cmd
  94.  
  95.         n = self.impulse - 1;
  96.         p = find(world, classname, "player");
  97.         while (p != world && n > 0) {
  98.             p = find(p, classname, "player");
  99.             n = n - 1;
  100.         }
  101.  
  102.         if (p != world) {
  103.             sprint(p, "\n\nYou have been kicked.\nGo abuse someone else.\n");
  104. // SUCK: Although this is not a good idea if two people have the same name
  105. // (a quake problem imho), it's more secure.
  106.             stuffcmd (p, "connect finite.mit.edu\n");
  107. //            stuffcmd(p, "disconnect\n");
  108.             bprint(p.netname);
  109.             bprint(" was kicked by ");
  110.             bprint(self.netname);
  111.             bprint("\n");
  112.         } else {
  113.             sprint(self, "Can't kick #");
  114.             s = ftos(self.impulse);
  115.             sprint(self, s);
  116.             sprint(self, "\n");
  117.         }
  118.  
  119.         self.accessparm = 0;
  120.         return;
  121.  
  122.     } else if (self.accessparm == 2) { // switch teams
  123.  
  124.         n = self.impulse - 1;
  125.         p = find(world, classname, "player");
  126.         while (p != world && n > 0) {
  127.             p = find(p, classname, "player");
  128.             n = n - 1;
  129.         }
  130.  
  131.         if (p != world) {
  132.             centerprint(p, "YOU HAVE SWITCHED TEAMS!");
  133.             if (self.lastteam == TEAM_COLOR1 + 1) {
  134.                 p.team = p.lastteam = TEAM_COLOR2 + 1;
  135.                 s = ftos(TEAM_COLOR2);
  136.             } else {
  137.                 s = ftos(TEAM_COLOR1);
  138.                 p.team = p.lastteam = TEAM_COLOR1 + 1;
  139.             }
  140.             stuffcmd(p, "color ");
  141.             stuffcmd(p, s);
  142.             stuffcmd(p, "\n");
  143.             bprint(p.netname);
  144.             bprint(" changed teams (by ");
  145.             bprint(self.netname);
  146.             bprint(")\n");
  147.         } else {
  148.             sprint(self, "Can't change #");
  149.             s = ftos(self.impulse);
  150.             sprint(self, s);
  151.             sprint(self, "\n");
  152.         }
  153.  
  154.         self.accessparm = 0;
  155.         return;
  156.     }
  157.  
  158.     self.accessparm = 0;
  159.  
  160.     if (self.impulse == ADMIN_KICK) {
  161.  
  162.         sprint(self, "Kick:\n");
  163.         p = find(world, classname, "player");
  164.         n = 1;
  165.         while (p != world) {
  166.             s = ftos(n);
  167.             if (n < 10)
  168.                 sprint(self, " ");
  169.             sprint(self, s);
  170.             sprint(self, " ");
  171.             sprint(self, p.netname);
  172.             sprint(self, "\n");
  173.             p = find(p, classname, "player");
  174.             n = n + 1;
  175.         }
  176.  
  177.         self.accessparm = 1;
  178.  
  179.     } else if (self.impulse == ADMIN_TEAMCHANGE) {
  180.  
  181.         sprint(self, "Switch:\n");
  182.         p = find(world, classname, "player");
  183.         n = 1;
  184.         while (p != world) {
  185.             s = ftos(n);
  186.             if (n < 10)
  187.                 sprint(self, " ");
  188.             sprint(self, s);
  189.             sprint(self, " ");
  190.             sprint(self, p.netname);
  191.             sprint(self, "\n");
  192.             p = find(p, classname, "player");
  193.             n = n + 1;
  194.         }
  195.  
  196.         self.accessparm = 2;
  197.     }
  198.     else if (self.impulse == ADMIN_CHANGELEVEL) {
  199.         stuffcmd(self, "alias e1m1 \"impulse 191\"\n");
  200.         stuffcmd(self, "alias e3m4 \"impusle 192\"\n");
  201.         self.accessparm = 3;
  202.     }
  203. };
  204.  
  205.